#include "max4466.h"

uint32_t Max4466_Getgrade(void)
{
	uint16_t adcval = 0;
	uint32_t grade = 0;
	
	for (uint32_t i=0; i<5; i++)
	{
		HAL_ADC_Start(&hadc1);
		HAL_ADC_PollForConversion(&hadc1, 0xffff);
		adcval += HAL_ADC_GetValue(&hadc1);
	}
	adcval = adcval/5;
	if (adcval > 2200)
	{
		grade = (adcval-2200)/10;
	}
	else
	{
		grade = 0;
	}
	return grade;
}
